//
//  HomeParticipationQWViewController.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/10/21.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "HomeParticipationQWViewController.h"

#import "HomeParticipationQWTableViewCell.h"

@interface HomeParticipationQWViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic, strong) UITableView * tableView;
@property(nonatomic, strong) UIButton * timeBut;//时间排序

@end

@implementation HomeParticipationQWViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //self.view.backgroundColor=[UIColor orangeColor];
    //表格添加到视图中
    [self.view addSubview:self.tableView];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;// 去掉所有cell的分割线
    
    //时间排序按钮
    [self setTimeButUp];
}
- (void)setTimeButUp
{
//    _timeBut=[[UIButton alloc] init];
//    [_timeBut setTitle:@"按时间排序" forState:UIControlStateNormal];
//    _timeBut.titleLabel.font=[UIFont systemFontOfSize:kWidthScale(11)];
//    [_timeBut setTitleColor:[UIColor colorWithHexString:@"#0059ff"] forState:UIControlStateNormal];
//    [_timeBut setBackgroundImage:[UIImage imageNamed:@"xialaanniu"] forState:UIControlStateNormal];
//    _timeBut.titleEdgeInsets = UIEdgeInsetsMake(5, 0, 5, 20);
    _timeBut=[[UIButton alloc] init];
    [_timeBut setBackgroundImage:[UIImage imageNamed:@"xialaanniu"] forState:UIControlStateNormal];
    [_timeBut setTitle:@"按时间排序" forState:UIControlStateNormal];
    [_timeBut setTitleColor:[UIColor colorWithHexString:@"#0059ff"] forState:UIControlStateNormal];
    _timeBut.titleLabel.font = [UIFont systemFontOfSize:kWidthScale(12)];
    _timeBut.titleEdgeInsets = UIEdgeInsetsMake(0, -95, 0, 0);
    [self.view addSubview:_timeBut];
    _timeBut.sd_layout
    .topSpaceToView(self.view, kHeightScale(43))
    .rightSpaceToView(self.view, kWidthScale(15))
    .widthIs(kWidthScale(15))
    .heightIs(kHeightScale(15));
}
//表格加载
//返回每个分区下的单元格个数，必须实现
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return kHeightScale(295);
}
/*设置标题尾的宽度*/
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return kHeightScale(50);
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString * str= @"biao";
    HomeParticipationQWTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        
        cell=[[HomeParticipationQWTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
    }
    cell.selectionStyle=UITableViewStylePlain;
    return cell;
}
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [self.navigationController pushViewController:[QualitycreationdetailsNBViewController new] animated:YES
//     ];
//}
//设置页眉的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return kHeightScale(25);
    
}
//自定义标题
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [UIView new];
    
    NSArray *arr = @[@"2017/09/23"];
    // 填充
    UILabel * lab2 = [[UILabel alloc]init];
    lab2.textAlignment = 0;
    lab2.font = [UIFont fontWithName:@ "Arial" size:kWidthScale(12)];
    lab2.textColor = [UIColor colorWithHexString:@"#666666"];
    lab2.text = arr[section];
    [view addSubview:lab2];
    lab2.sd_layout
    .centerYEqualToView(view)
    .leftSpaceToView(view, kWidthScale(15))
    .widthIs(kWidthScale(100))
    .autoHeightRatio(0);
    view.backgroundColor = [UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];
    return view;
}
- (UITableView *)tableView
{
    if (!_tableView)
    {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kHeightScale(66), UIScreenWidth, UIScreenHeight-70) style:UITableViewStylePlain];
        
        _tableView.delegate = self;
        
        _tableView.dataSource = self;
    }
    return _tableView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
